//
//  MeiFsecController.m
//  MyProject
//
//  Created by dllo on 15/11/18.
//  Copyright © 2015年 蓝鸥0825. All rights reserved.
//

#import "MeiFsecController.h"

@interface MeiFsecController () <UIWebViewDelegate>
{
    UIWebView *_web;
    UIActivityIndicatorView *activityIndicator;
}
@end

@implementation MeiFsecController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    _web = [[UIWebView   alloc] initWithFrame:self.view.bounds];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.str]];
    [self.view addSubview:_web];
    [_web loadRequest:request];
    [_web release];
    NSLog(@"%@", self.str);
    
    
    _web.delegate=self;
    UIScrollView *scollview=(UIScrollView *)[[_web subviews]objectAtIndex:0];
    scollview.bounces=NO;
    
    
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}


//      网页开始加载的时候调用
- (void )webViewDidStartLoad:(UIWebView  *)webView{
    
    //创建UIActivityIndicatorView背底半透明View
    UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
    [view setTag:108];
    [view setBackgroundColor:[UIColor blackColor]];
    [view setAlpha:0.5];
    [self.view addSubview:view];
    
    
    
    
    
    //      指定进度轮的大小
    activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
    
    //      指定进度轮中心点
    [activityIndicator setCenter:view.center];
    
    //      设置进度轮显示类型, 系统提供了三种类型
    [activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
    
    
    //      设置背景色
    activityIndicator.backgroundColor = [UIColor grayColor];
    
    //      设置背景透明
    activityIndicator.alpha = 0.5;
    
    //      设置背景为圆角矩形
    activityIndicator.layer.cornerRadius = 6;
    activityIndicator.layer.masksToBounds = YES;
    
    
    //      将初始化好的indicator add到view中 ,可以将它附着在任何视图上，比如表格单元、或者视图：
    [view addSubview:activityIndicator];
    [activityIndicator startAnimating];
}


//      网页加载完成的时候调用
- (void )webViewDidFinishLoad:(UIWebView  *)webView{
    
    [activityIndicator stopAnimating];
    UIView *view = (UIView*)[self.view viewWithTag:108];
    [view removeFromSuperview];
    NSLog(@"webViewDidFinishLoad");
    
}


//      网页加载错误的时候调用
- (void)webView:(UIWebView *)webView  didFailLoadWithError:(NSError *)error{
    [activityIndicator stopAnimating];
    UIView *view = (UIView*)[self.view viewWithTag:108];
    [view removeFromSuperview];
    NSLog(@"sha");
}




@end
